/**
 * trayinfo.h
 */

#ifndef _TRAYINFO_H
#define _TRAYINFO_H	1

#include <sys/time.h>
#include <sys/types.h>

#ifdef HAVE_CONFIG_H
# include "config.h"
#endif /* HAVE_CONFIG_H */

/* location of the config under the current user's home directory */
#define CONFIG_FNAME	"/.config/trayinfo"

/* seconds to wait before a reconnect attempt */
#define WAIT_RETRY	30

void put_separator(void);

typedef int (*cfg_handler_t)(const char *s);

void cfg_add_handler(const char *name, cfg_handler_t handler);

typedef struct {
	const char *name;
	void (*init)(void);
	void (*done)(void);
	int (*write)(struct timeval *now, int fd);
	int (*open)(void);
	void (*close)(int fd);
	ssize_t (*read)(int fd);

	int fd;
	int last_retry;
	int wait_retry;
} src_t;

typedef void (*src_regfunc_t)(src_t *src);

/* trayinfo can only use sources listed below */
void regsrc_time(src_t *src);
void regsrc_netspeed(src_t *src);
void regsrc_cpu(src_t *src);
void regsrc_sensor(src_t *src);
void regsrc_acpitemp(src_t *src);
void regsrc_acpibatt(src_t *src);
void regsrc_mpd(src_t *src);
void regsrc_mhz(src_t *src);
void regsrc_ldavg(src_t *src);
void regsrc_gmail(src_t *src);

#endif /* _TRAYINFO_H */
